<?xml version="1.0"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
  "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"
      xmlns:tal="http://xml.zope.org/namespaces/tal"
      xmlns:metal="http://xml.zope.org/namespaces/metal">
  <head>
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
    <style>
      table {
      	page-break-before: auto;
      	page-break-inside: avoid;
      	page-break-after: auto;
      	margin-bottom: 1em;
      }
      tbody, thead, tr, td {
	      page-break-before: avoid;
	      page-break-after: avoid;
      }
      td, th {
  	    white-space: nowrap;
      }
      .left {
        text-align: left;
      }
      .center {
        text-align: center;
      }
      .right {
        text-align: right;
      }
    </style>
  </head>
  <body>
    <table>
      <thead>
        <tr>
          <th class="left">Tuottaja</th>
          <th class="left">Tuote</th>
          <tal:deliveries repeat="order orders">
            <th class="right" tal:content="php:date('d.m.y', order.date)">1.6.2009</th>
          </tal:deliveries>
        </tr>
      </thead>
      <tbody>
        <tal:producer repeat="producer php:array_keys(products)">
          <tr tal:repeat="product php:array_keys(products[producer])">
            <td class="left" tal:content="producer|string:(Ei tiedossa)">
              Tuottajan nimi
            </td>
            <td class="left" tal:content="product">
              Tuotteen nimi
            </td>
            <tal:deliveries repeat="order orders">
              <td tal:define="date php:array_key_exists(order.date, products[producer][product]) ? order.date : NULL;
                              sum  php:date ? products[producer][product][date] : '0.00'"
                      class="right">
                <span tal:replace="php:str_replace('.', ',', sum)">10,00</span> &euro;
              </td>
            </tal:deliveries>
          </tr>
        </tal:producer>
      </tbody>
    </table>
  </body>
</html>